//app.js
App({
  onLaunch: function () {
      
  },
  api:require("api.js"),
  onShow:function(){
    var _this = this;
  },

  request: function (a) {
    a.data || (a.data = {});
    var t = wx.getStorageSync("access_token");
    t && (a.data.access_token = t);
      wx.request({
        url: a.url,
        header: a.header || {
          "content-type": "application/x-www-form-urlencoded"
        },
        header: a.header || {
          "content-type": "application/json"
        },
        data: a.data || {},
        method: a.method || "GET",
        dataType: a.dataType || "json",
        success: function (t) {
          if (-1 == t.data.code){wx.showToast({
            title: t.data.msg,
            icon:'none',
          })
            return false;
          }
          -100 == t.data.code ? wx.showModal({
            title: '提示',
            content: res.msg,
            showCancel:false,
            success:function(){
              wx.removeStorageSync('access_token');
              wx.switchTab({
                url: '/pages/home/home',
              })
            }
          }) : a.success && a.success(t.data);
        },
        fail: function (t) {
          console.warn("--- request fail >>>"), console.warn(t), console.warn("<<< request fail ---");
          var e = getApp();
          e.is_on_launch ? (e.is_on_launch = !1, wx.showModal({
            title: "网络请求出错",
            content: t.errMsg,
            showCancel: !1,
            success: function (t) {
              t.confirm && a.fail && a.fail(t);
            }
          })) : (wx.showToast({
            title: t.errMsg,
            icon:'none'
          }), a.fail && a.fail(t));
        },
        complete: function (t) {
          200 != t.statusCode && (console.log("--- request http error >>>"), console.log(t.statusCode),
            console.log(t.data), console.log("<<< request http error ---")), a.complete && a.complete(t);
        }
      });
  },
  globalData: {
    equipment_id:0,
    order_list:[],
    order_price:0.00,
    ad:false
  }
})